<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class cartesian_communicator</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../mpi/reference.html#header.boost.mpi.cartesian_communicator_hpp" title="Header &lt;boost/mpi/cartesian_communicator.hpp&gt;">
<link rel="prev" href="operator__1_3_25_7_2_2_1_4.html" title="Function template operator!=">
<link rel="next" href="cartesian_dimension.html" title="Struct cartesian_dimension">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="operator__1_3_25_7_2_2_1_4.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../mpi/reference.html#header.boost.mpi.cartesian_communicator_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="cartesian_dimension.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.mpi.cartesian_communicator"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class cartesian_communicator</span></h2>
<p>boost::mpi::cartesian_communicator — An MPI communicator with a cartesian topology. </p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../mpi/reference.html#header.boost.mpi.cartesian_communicator_hpp" title="Header &lt;boost/mpi/cartesian_communicator.hpp&gt;">boost/mpi/cartesian_communicator.hpp</a>&gt;

</span>
<span class="keyword">class</span> <a class="link" href="cartesian_communicator.html" title="Class cartesian_communicator">cartesian_communicator</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mpi</span><span class="special">::</span><span class="identifier">communicator</span> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// <a class="link" href="cartesian_communicator.html#boost.mpi.cartesian_communicatorconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_5-bb"><span class="identifier">cartesian_communicator</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MPI_Comm</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">comm_create_kind</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_6-bb"><span class="identifier">cartesian_communicator</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="communicator.html" title="Class communicator">communicator</a> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <span class="special">&amp;</span><span class="special">,</span> 
                         <span class="keyword">bool</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_7-bb"><span class="identifier">cartesian_communicator</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="cartesian_communicator.html" title="Class cartesian_communicator">cartesian_communicator</a> <span class="special">&amp;</span><span class="special">,</span> 
                         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_4-bb">public member functions</a></span>
  <span class="keyword">int</span> <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_4_1-bb"><span class="identifier">ndims</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">int</span> <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_4_2-bb"><span class="identifier">rank</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span> <span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">&gt;</span> <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_4_3-bb"><span class="identifier">shifted_ranks</span></a><span class="special">(</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_4_4-bb"><span class="identifier">coordinates</span></a><span class="special">(</span><span class="keyword">int</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_4_5-bb"><span class="identifier">topology</span></a><span class="special">(</span><a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_4_6-bb"><span class="identifier">topology</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">int</span> <a class="link" href="cartesian_communicator.html#id-1_3_25_7_3_2_1_1_4_7-bb"><span class="identifier">rank</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.25.7.4.4.4"></a><h2>Description</h2>
<p>A <code class="computeroutput"><a class="link" href="cartesian_communicator.html" title="Class cartesian_communicator">cartesian_communicator</a></code> is a communicator whose topology is expressed as a grid. Cartesian communicators have the same functionality as (intra)communicators, but also allow one to query the relationships among processes and the properties of the grid. </p>
<div class="refsect2">
<a name="id-1.3.25.7.4.4.4.3"></a><h3>
<a name="boost.mpi.cartesian_communicatorconstruct-copy-destruct"></a><code class="computeroutput">cartesian_communicator</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_25_7_3_2_1_1_5-bb"></a><span class="identifier">cartesian_communicator</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MPI_Comm</span> <span class="special">&amp;</span> comm<span class="special">,</span> <span class="identifier">comm_create_kind</span> kind<span class="special">)</span><span class="special">;</span></pre>
<p>Build a new Boost.MPI cartesian communicator based on the MPI communicator <code class="computeroutput">comm</code> with cartesian topology.</p>
<p><code class="computeroutput">comm</code> may be any valid MPI communicator. If <code class="computeroutput">comm</code> is MPI_COMM_NULL, an empty communicator (that cannot be used for communication) is created and the <code class="computeroutput">kind</code> parameter is ignored. Otherwise, the <code class="computeroutput">kind</code> parameter determines how the Boost.MPI communicator will be related to <code class="computeroutput">comm:</code> </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>If <code class="computeroutput">kind</code> is <code class="computeroutput">comm_duplicate</code>, duplicate <code class="computeroutput">comm</code> to create a new communicator. This new communicator will be freed when the Boost.MPI communicator (and all copies of it) is destroyed. This option is only permitted if the underlying MPI implementation supports MPI 2.0; duplication of intercommunicators is not available in MPI 1.x.</p></li>
<li class="listitem"><p>If <code class="computeroutput">kind</code> is <code class="computeroutput">comm_take_ownership</code>, take ownership of <code class="computeroutput">comm</code>. It will be freed automatically when all of the Boost.MPI communicators go out of scope.</p></li>
<li class="listitem"><p>If <code class="computeroutput">kind</code> is <code class="computeroutput">comm_attach</code>, this Boost.MPI communicator will reference the existing MPI communicator <code class="computeroutput">comm</code> but will not free <code class="computeroutput">comm</code> when the Boost.MPI communicator goes out of scope. This option should only be used when the communicator is managed by the user. </p></li>
</ul></div>
<p>
</p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_25_7_3_2_1_1_6-bb"></a><span class="identifier">cartesian_communicator</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="communicator.html" title="Class communicator">communicator</a> <span class="special">&amp;</span> comm<span class="special">,</span> 
                       <span class="keyword">const</span> <a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <span class="special">&amp;</span> dims<span class="special">,</span> <span class="keyword">bool</span> reorder <span class="special">=</span> <span class="keyword">false</span><span class="special">)</span><span class="special">;</span></pre>
<p>Create a new communicator whose topology is described by the given cartesian. The indices of the vertices in the cartesian will be assumed to be the ranks of the processes within the communicator. There may be fewer vertices in the cartesian than there are processes in the communicator; in this case, the resulting communicator will be a NULL communicator.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">comm</code></span></p></td>
<td><p>The communicator that the new, cartesian communicator will be based on.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">dims</code></span></p></td>
<td><p>the cartesian dimension of the new communicator. The size indicate the number of dimension. Some dimensions be set to zero, in which case the corresponding dimension value is left to the system.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">reorder</code></span></p></td>
<td><p>Whether MPI is permitted to re-order the process ranks within the returned communicator, to better optimize communication. If false, the ranks of each process in the returned process will match precisely the rank of that process within the original communicator. </p></td>
</tr>
</tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_25_7_3_2_1_1_7-bb"></a><span class="identifier">cartesian_communicator</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="cartesian_communicator.html" title="Class cartesian_communicator">cartesian_communicator</a> <span class="special">&amp;</span> comm<span class="special">,</span> 
                       <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span> keep<span class="special">)</span><span class="special">;</span></pre>
<p>Create a new cartesian communicator whose topology is a subset of an existing cartesian cimmunicator. 
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">comm</code></span></p></td>
<td><p>the original communicator. </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">keep</code></span></p></td>
<td><p>and array containiing the dimension to keep from the existing communicator. </p></td>
</tr>
</tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.25.7.4.4.4.4"></a><h3>
<a name="id-1_3_25_7_3_2_1_1_4-bb"></a><code class="computeroutput">cartesian_communicator</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">int</span> <a name="id-1_3_25_7_3_2_1_1_4_1-bb"></a><span class="identifier">ndims</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Retrive the number of dimension of the underlying toppology. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">int</span> <a name="id-1_3_25_7_3_2_1_1_4_2-bb"></a><span class="identifier">rank</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span> coords<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Return the rank of the process at the given coordinates. 
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">coords</code></span></p></td>
<td><p>the coordinates. the size must match the communicator's topology. </p></td>
</tr></tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span> <span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">&gt;</span> <a name="id-1_3_25_7_3_2_1_1_4_3-bb"></a><span class="identifier">shifted_ranks</span><span class="special">(</span><span class="keyword">int</span> dim<span class="special">,</span> <span class="keyword">int</span> disp<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Return the rank of the source and target destination process through a shift. 
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">dim</code></span></p></td>
<td><p>the dimension in which the shift takes place. 0 &lt;= dim &lt;= ndim(). </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">disp</code></span></p></td>
<td><p>the shift displacement, can be positive (upward) or negative (downward). </p></td>
</tr>
</tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <a name="id-1_3_25_7_3_2_1_1_4_4-bb"></a><span class="identifier">coordinates</span><span class="special">(</span><span class="keyword">int</span> rk<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Provides the coordinates of the process with the given rank. 

</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">rk</code></span></p></td>
<td><p>the ranks in this communicator. </p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>the coordinates. </p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="id-1_3_25_7_3_2_1_1_4_5-bb"></a><span class="identifier">topology</span><span class="special">(</span><a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <span class="special">&amp;</span> dims<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span> coords<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Retrieve the topology and coordinates of this process in the grid. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <a name="id-1_3_25_7_3_2_1_1_4_6-bb"></a><span class="identifier">topology</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Retrieve the topology of the grid. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">int</span> <a name="id-1_3_25_7_3_2_1_1_4_7-bb"></a><span class="identifier">rank</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Determine the rank of the executing process in a communicator. <p>This routine is equivalent to <code class="computeroutput">MPI_Comm_rank</code>.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The rank of the process in the communicator, which will be a value in [0, size()) </p></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2005-2007 Douglas Gregor,
      Matthias Troyer, Trustees of Indiana University<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at &lt;ulink url="http://www.boost.org/LICENSE_1_0.txt"&gt;
        http://www.boost.org/LICENSE_1_0.txt &lt;/ulink&gt;)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="operator__1_3_25_7_2_2_1_4.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../mpi/reference.html#header.boost.mpi.cartesian_communicator_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="cartesian_dimension.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
